package classnameobtainandprint;

import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class StudentDataTest {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("----------欢迎进入随机点名系统----------");
		List<String> classes = ClassName.getClassName();
		System.out.println("共用" + classes.size() + "个班！\n分别是：");
		int num = 1;
		for (String name : classes) {
			System.out.println(num + ": " + name);
			num++;
		}
		System.out.print("请选择班级（序号）：");
		int classNameNum = input.nextInt();
		List<Student> students = StudentBusiness.getStudents(classes.get(classNameNum-1) + ".txt");

		// 插入信息
		Student s1 = new Student("005", "二狗", 66);
		Student s2 = new Student("006", "四柱",88);
		students.add(0, s1);
		students.add(4, s2);
		// LinkedList特有方法students.addFirst(s1);————将s1添加到第一个位置（其他数据位置下移）
		
		// Set列表输出方法
		Iterator<Student> iterator = students.iterator();
		while ( iterator.hasNext()) {
			System.out.println(iterator.next());
		}
		
//		// get不适用于Set方法
//		for (int i=0;i<students.size();i++) {
//			System.out.println(students.get(i).getSno() + " " + students.get(i).getName());
//		}
	
	}
}
